package com.tongji;

import android.view.GestureDetector;
import android.view.MotionEvent;

public class MyGestureDetector extends GestureDetector {
	private OnMyGestureListener mListener;
	//private MotionEvent mInitialEvent;
	private int mMoveCount;
	
	interface OnMyGestureListener extends OnGestureListener {
		public boolean onMultiScroll(MotionEvent e1, MotionEvent e2);
	}

	public MyGestureDetector(OnMyGestureListener listener) {
		super(listener);
		mListener = listener;
	}

	@Override
	public boolean onTouchEvent(MotionEvent ev) {
		/*if (ev.getPointerCount() == 2) {
			if (ev.getAction() == MotionEvent.ACTION_POINTER_2_DOWN) {
				mInitialEvent = MotionEvent.obtain(ev);
				//mListener.onDown(ev);
			}
			else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
				return mListener.onMultiScroll(mInitialEvent, ev);
			}
		}*/
		if (ev.getAction() == MotionEvent.ACTION_DOWN) {
			mMoveCount = 0;
		}
		else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
			mMoveCount++;
		}
		else if (ev.getAction() == MotionEvent.ACTION_UP && mMoveCount != 1) {
			return mListener.onSingleTapUp(ev);
		}
		return super.onTouchEvent(ev);
	}

}
